package appBCN.version;

import java.util.List;
import java.util.Random;

import android.content.Context;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;

@SuppressWarnings("rawtypes")
public class SimpleAdapterList extends ArrayAdapter {
	private int[] colors = new int[] { 0x6633FF00, 0x55555555 };
	
	

	/**
	 * @param context
	 * @param resource
	 * @param textViewResourceId
	 * @param objects
	 */
	@SuppressWarnings({ "unchecked"})
	public SimpleAdapterList(Context context, int resource,
			int textViewResourceId, List objects) {
		super(context, resource, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}



	/**
	 * @param context
	 * @param resource
	 * @param textViewResourceId
	 * @param objects
	 */
	@SuppressWarnings("unchecked")
	public SimpleAdapterList(Context context, int resource,
			int textViewResourceId, Object[] objects) {
		super(context, resource, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}



	/**
	 * @param context
	 * @param textViewResourceId
	 * @param objects
	 */
	@SuppressWarnings("unchecked")
	public SimpleAdapterList(Context context, int textViewResourceId,
			Object[] objects) {
		super(context, textViewResourceId, objects);
		// TODO Auto-generated constructor stub
	}



	@Override
	public View getView(int position, View convertView, ViewGroup parent) {
	  View view = super.getView(position, convertView, parent);
	  int colorPos = position % colors.length;
	  if(colorPos == 1)
		  colorPos = new Random().nextInt(2);
	  if(colorPos == 1){
		  view.setEnabled(false);
		  view.setClickable(false);
		  view.setOnClickListener(null);
	  }
	  view.setBackgroundColor(colors[colorPos]);
	  return view;
	}
}
